package com.usian.service.impl;

import com.usian.mapper.BumenMapper;
import com.usian.mapper.CompanyMapper;
import com.usian.mapper.FunctionMapper;
import com.usian.pojo.Bumen;
import com.usian.pojo.DTO;
import com.usian.pojo.Function;
import com.usian.pojo.Staff;
import com.usian.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private CompanyMapper companyMapper;

    @Autowired
    private BumenMapper bumenMapper;

    @Autowired
    private FunctionMapper  functionMapper;

    @Override
    public List<DTO> findAll() {
        return companyMapper.findAll();
    }

    @Override
    public List<Bumen> findBumen() {
        return bumenMapper.selectAll();
    }

    @Override
    public List<Function> findFunction() {
        return functionMapper.selectAll();
    }

    @Override
    public void add(Staff staff) {
        companyMapper.insert(staff);
    }

    @Override
    public void delete(Integer sid) {
        companyMapper.deleteByPrimaryKey(sid);
    }

    @Override
    public Staff findById(Integer sid) {
        return companyMapper.findById(sid);
    }

    @Override
    public void update(Staff staff) {
        companyMapper.updateByPrimaryKeySelective(staff);
    }

    @Override
    public Staff findName(String sname) {
        Staff staff =  companyMapper.findByName(sname);
        return staff;
    }

    @Override
    public Staff findByName(String username) {
        Staff staff = companyMapper.findByName(username);
        return staff ;
    }

    @Override
    public List<DTO> ById(Integer bid) {
        List<DTO> list = companyMapper.ById(bid);
        return list;
    }
}
